<template>
	<view class="beijingse mainpadding" v-if="pageShow">
		<view class="" style="padding-bottom: 100rpx;">
			<view class="bigtext fonweight" v-if="dataAll.state==1">等待买家付款</view>
			<view class="bigtext fonweight" v-if="dataAll.state==3 && dataAll.buy_type==2">待核销</view>
			<view class="bigtext fonweight" v-if="dataAll.state==2 && dataAll.order_type==2">等待商家发货</view>
			<view class="bigtext fonweight" v-if="dataAll.state==2 && dataAll.order_type==1">备货中</view>
			<view class="bigtext fonweight" v-if="dataAll.state==3 && dataAll.buy_type==1">等待买家收货</view>
			<view class="bigtext fonweight" v-if="dataAll.state==4">待评价</view>
			<view class="bigtext fonweight" v-if="dataAll.state==6">已完成</view>
			<view class="bigtext fonweight" v-if="dataAll.state==7">已取消</view>
			<view class=" ffffff mainpadding margin_top">
				<!-- <view class="titletext zhonghei fonweight">肯德基</view> -->
				<view class="flexbetween" v-for="item in dataAll.goods" :key="item.id">
					<image class="sptp margin_right" :src="item.image_text" mode=""></image>
					<view class="flexcolumnbet" style="width: 77%;height: 150rpx;">
						<view class="ershiba xiaohei yhxk">{{item.title}}</view>
						<view class="ershil xiaohui">x{{item.number}}</view>
						<view class="titletext xiaohong fonweight">¥{{item.actual_payment}}</view>
					</view>
				</view>
			</view>
			<view class="ffffff radius mainpadding margin_top">
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">合计</view>
					<view class="ershil xiaohui">￥{{dataAll.total_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">联盟积分抵扣</view>
					<view class="ershil xiaohui">￥{{dataAll.score_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">首单优惠</view>
					<view class="ershil xiaohui">￥{{dataAll.sdyh_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">优惠券</view>
					<view class="ershil xiaohui">￥{{dataAll.coupon_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">实际支付</view>
					<view class="ershil xiaohong">¥{{dataAll.pay_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">订单编号</view>
					<view class="ershil xiaohui">{{dataAll.order_no}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">下单时间</view>
					<view class="ershil xiaohui">{{dataAll.createtime_text}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">支付方式</view>
					<view class="ershil xiaohui">{{dataAll.pay_type==10?"微信支付":"余额支付"}}</view>
				</view>
				<view class="margin_top" v-if="dataAll.remarks">
					<text class="ershil zhonghei">备注：</text>
					<text class="ershil xiaohui">{{dataAll.remarks}}</text>
				</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding flexright">
			<view class="xhbtn flexcenter" v-if="dataAll.state==2 && dataAll.order_type==1" @click.stop="beihuo(dataAll.id)">立即备货</view>
			<view class="xhbtn flexcenter" v-if="dataAll.state==2 && dataAll.order_type==2" @click.stop="currentid=dataAll.id;show=true">立即发货</view>
			<view class="xhbtn flexcenter" v-if="dataAll.state==3 && dataAll.buy_type==2" @click.stop="hexiao(dataAll.hx_code)">核销订单</view>
		</view>
		<u-popup :show="show" @close="show=false" :safeAreaInsetBottom="false" mode="center" :round="10">
			<view class="mainpadding">
				<view class="sanshier textcenter fonweight zhonghei">发货</view>
				<view class="flexbetween margin_top5">
					<view class="ershib zhonghei margin_right">快递公司</view>
					<input type="text" placeholder="请输入" style="width: 60%;" v-model="express_name">
				</view>
				<view class="flexbetween margin_top5">
					<view class="ershib zhonghei margin_right">快递单号</view>
					<input type="text" placeholder="请输入" style="width: 60%;" v-model="express_no">
				</view>
				<view class="flexbetween margin_top5">
					<view class="qxdtn flexcenter margin_right" @click="show=false">取消</view>
					<view class="qubtn flexcenter" @click="fahuo(currentid)">确认</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				shop_id: "",
				dataAll: {},
				pageShow:false,
				show: false,
				currentid:"",
				express_no:"",
				express_name:"",
			}
		},
		onLoad(option) {
			this.listid = option.id
			this.shop_id = option.id
		},
		onShow() {
			this.getDetail()
		},
		methods: {
			beihuo(id) {
				httpRequest.modal('提示', '是否对当前订单进行备货操作', true, (resp) => {
					if (resp) {
						httpRequest.request('/api/shopcl/orderBh', 'GET', {
							order_id: id,
							shop_id:this.shop_id
						}).then(res => {
							httpRequest.toast(res.msg)
							if(res.code==1){
								this.getDetail()
							}
						})
					}
				})
			},
			fahuo(id){
				if(this.express_name==""){
					httpRequest.toast("请输入快递公司名称")
					return false
				}
				if(this.express_no==""){
					httpRequest.toast("请输入快递单号")
					return false
				}
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/shopcl/orderFh', 'GET', {
					order_id: id,
					express_name:this.express_name,
					express_no:this.express_no,
				}).then(res => {
					uni.hideLoading()
					this.show=false
					httpRequest.toast(res.msg)
					if(res.code==1){
						this.express_name = ""
						this.express_no = ""
						this.getDetail()
					}
				})
			},
			hexiao(hx_code){
				uni.navigateTo({
					url:"/pages_wode/heixiao?hx_code="+hx_code
				})
			},
			getDetail() {
				httpRequest.request('/api/shopcl/orderDetail', 'GET', {
					order_id: this.listid,
				}).then(res => {
					this.pageShow = true
					this.dataAll = res.data

				})
			},
			// 跳转去回复评价
			tzqpk() {
				uni.navigateTo({
					url: '/pages_wode/dianpushangppj'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.hexm {
		width: 167rpx;
		height: 167rpx;
		margin: auto;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.xhbtn {
		width: 170rpx;
		height: 67rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FF9341;
		border-radius: 120rpx;
		border: 2rpx solid #FF9341;
	}

	.qxbtn {
		width: 170rpx;
		height: 67rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #666666;
		border-radius: 120rpx;
		border: 2rpx solid #666666;
	}

	.sptp {
		width: 124rpx;
		height: 124rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}
</style>